package com.linkhub.oms.admin.modules.stock.domain.vo;

import com.linkhub.oms.admin.modules.stock.enums.BusinessType;
import com.linkhub.oms.admin.modules.stock.enums.ProductType;
import com.linkhub.oms.common.enums.IEnumConvert;
import com.linkhub.oms.common.util.QtBeanUtil;
import com.linkhub.oms.entity.resulttype.stock.ProductStockResultEntity;
import com.linkhub.oms.entity.resulttype.stock.StockFlowResultEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * @ClassName StockFlowVO
 * @Description TODO
 * @Author XieYu
 * @Date 2024/6/24 22:29
 * @Version 1.0
 */
@Data
@ApiModel(value = "StockFlowVO", description = "库存流水对象")
public class StockFlowVO implements Serializable {

    @ApiModelProperty(value = "业务时间")
    private String time;

    @ApiModelProperty(value = "仓库名称")
    private String stashName;

    @ApiModelProperty(value = "业务类型")
    private String businessType;

    @ApiModelProperty(value = "业务单号")
    private String businessNo;

    @ApiModelProperty(value = "本地商品skuId")
    private String skuId;

    @ApiModelProperty(value = "sku")
    private String sku;

    @ApiModelProperty(value = "产品名称")
    private String productEnTitle;

    @ApiModelProperty(value = "原库存量|分配库存")
    private Integer beforeAmount;

    @ApiModelProperty(value = "商家名称")
    private String merchantUserName;

    @ApiModelProperty(value = "加减数量")
    private Integer amount;

    @ApiModelProperty(value = "库存结余")
    private Integer afterAmount;

    @ApiModelProperty(value = "库存状态")
    private Integer status;

    public static StockFlowVO convert(StockFlowResultEntity entity) {
        StockFlowVO vo = new StockFlowVO();
        QtBeanUtil.copyProperties(entity, vo);
        if (Objects.isNull(vo.getStatus())) {
            vo.setStatus(ProductType.GOOD.getValue());
        }
        vo.setBusinessType(IEnumConvert.valueOf(entity.getBusinessType(), BusinessType.class).getDesc());

        return vo;
    }
}
